package ebj.common.reflection;

import ebj.common.domain.ChinesePerson;
import ebj.common.utils.Utils;

/**
 * 反射实例5：返回一个类实现的接口 和 父类
 * @author zhouxiangyong
 * @version $Id$
 */
public class ReflectClient5 {
	public static void main(String[] args) {
		String clazzName = Utils.getProperty("ChinesePerson");
		Class<?> clazz = null;
		ChinesePerson chinesePerson = null;
		try {
			clazz = Class.forName(clazzName);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		
		try {
			chinesePerson = (ChinesePerson) clazz.newInstance();
			chinesePerson.sayChinese();
			chinesePerson.setGender("男");
			System.out.println(chinesePerson.getGender());
			chinesePerson.sayHello();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
		
		Class<?>[] interfaces = clazz.getInterfaces();
		if (interfaces.length > 0) {
			for (Class<?> class1 : interfaces) {
				System.out.println("当前类实现了接口: [" + class1.getName() + "]");
			}
		}
		Class<?> superClazz = clazz.getSuperclass();
		System.out.println("当前类的父类: [" + superClazz.getName() + "]");
	}
}
